package com.key.w8.http1.handler.codec;

import com.key.w8.http1.connection.Connection;
import com.key.w8.http1.entity.HttpObject;
import com.key.w8.http1.entity.HttpRequest;
import com.key.w8.http1.entity.HttpResponse;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpHeaders;

import java.nio.ByteBuffer;

/**
 * @Author: k8
 * @CreateTime: 2025-02-27
 * @Version: 1.0
 */
public class ConnectionHttp1Codec extends Http1Codec{
    private Connection connection;

    public ConnectionHttp1Codec() {

    }

    public Connection getConnection() {
        return connection;
    }

    @Override
    public void setConnection(Connection connection) {
        this.connection = connection;
    }




    @Override
    public void onResponseRead(HttpResponse response) throws Exception {
        connection.onResponseRead(response);
    }

    @Override
    public void onRequestRead(HttpRequest request) throws Exception {
        connection.onRequestRead(request);
    }

    @Override
    protected void onReadError(HttpObject httpObject,Throwable throwable) {
        connection.onExecuteError(httpObject,throwable);
    }
}
